<?php
/**
 * RecordTypeReportBody
 *
 * PHP version 5
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */

/**
 * Amazon Ads API - Sponsored Brands
 *
 * Use the Amazon Ads API for Sponsored Brands for campaign, ad group, keyword, negative keyword, drafts, Stores, landing pages, and Brands management operations. For more information about Sponsored Brands, see the [Sponsored Brands Support Center](https://advertising.amazon.com/help#GQFZA83P55P747BZ). For onboarding information, see the [account setup](https://advertising.amazon.com/API/docs/v3/guides/account_setup) topic.
 *
 * OpenAPI spec version: 3.0
 * 
 * Generated by:https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api.git
 * AmazonAdvertisingApi Codegen version: 3.0.51
 */
/**
 * NOTE: This class is auto generated by the AmazonAdvertisingApi code generator program.
 *https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 * Do not edit the class manually.
 */

namespace AmazonAdvertisingApi\Model;

use \ArrayAccess;
use \AmazonAdvertisingApi\ObjectSerializer;

/**
 * RecordTypeReportBody Class Doc Comment
 *
 * @category Class
 * @package  AmazonAdvertisingApi
 * @author   vv_guo
 * @link    https://gitee.com/HuaLiLiDeDiDiao/amazon-advertising-api
 */
class RecordTypeReportBody implements ModelInterface, ArrayAccess
{
    const DISCRIMINATOR = null;

    /**
      * The original name of the model.
      *
      * @var string
      */
    protected static $AmazonAdvertisingApiModelName = 'recordType_report_body';

    /**
      * Array of property to type mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiTypes = [
        'report_date' => 'string',
        'segment' => 'string',
        'creative_type' => 'string',
        'metrics' => 'string'
    ];

    /**
      * Array of property to format mappings. Used for (de)serialization
      *
      * @var string[]
      */
    protected static $AmazonAdvertisingApiFormats = [
        'report_date' => null,
        'segment' => null,
        'creative_type' => null,
        'metrics' => null
    ];

    /**
     * Array of property to type mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiTypes()
    {
        return self::$AmazonAdvertisingApiTypes;
    }

    /**
     * Array of property to format mappings. Used for (de)serialization
     *
     * @return array
     */
    public static function AmazonAdvertisingApiFormats()
    {
        return self::$AmazonAdvertisingApiFormats;
    }

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @var string[]
     */
    protected static $attributeMap = [
        'report_date' => 'reportDate',
        'segment' => 'segment',
        'creative_type' => 'creativeType',
        'metrics' => 'metrics'
    ];

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @var string[]
     */
    protected static $setters = [
        'report_date' => 'setReportDate',
        'segment' => 'setSegment',
        'creative_type' => 'setCreativeType',
        'metrics' => 'setMetrics'
    ];

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @var string[]
     */
    protected static $getters = [
        'report_date' => 'getReportDate',
        'segment' => 'getSegment',
        'creative_type' => 'getCreativeType',
        'metrics' => 'getMetrics'
    ];

    /**
     * Array of attributes where the key is the local name,
     * and the value is the original name
     *
     * @return array
     */
    public static function attributeMap()
    {
        return self::$attributeMap;
    }

    /**
     * Array of attributes to setter functions (for deserialization of responses)
     *
     * @return array
     */
    public static function setters()
    {
        return self::$setters;
    }

    /**
     * Array of attributes to getter functions (for serialization of requests)
     *
     * @return array
     */
    public static function getters()
    {
        return self::$getters;
    }

    /**
     * The original name of the model.
     *
     * @return string
     */
    public function getModelName()
    {
        return self::$AmazonAdvertisingApiModelName;
    }

    const SEGMENT_PLACEMENT = 'placement';
    const SEGMENT_QUERY = 'query';
    const CREATIVE_TYPE_VIDEO = 'video';
    const CREATIVE_TYPE_ALL = 'all';

    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getSegmentAllowableValues()
    {
        return [
            self::SEGMENT_PLACEMENT,
            self::SEGMENT_QUERY,
        ];
    }
    /**
     * Gets allowable values of the enum
     *
     * @return string[]
     */
    public function getCreativeTypeAllowableValues()
    {
        return [
            self::CREATIVE_TYPE_VIDEO,
            self::CREATIVE_TYPE_ALL,
        ];
    }

    /**
     * Associative array for storing property values
     *
     * @var mixed[]
     */
    protected $container = [];

    /**
     * Constructor
     *
     * @param mixed[] $data Associated array of property values
     *                      initializing the model
     */
    public function __construct(array $data = null)
    {
        $this->container['report_date'] = isset($data['report_date']) ? $data['report_date'] : null;
        $this->container['segment'] = isset($data['segment']) ? $data['segment'] : null;
        $this->container['creative_type'] = isset($data['creative_type']) ? $data['creative_type'] : null;
        $this->container['metrics'] = isset($data['metrics']) ? $data['metrics'] : null;
    }

    /**
     * Show all the invalid properties with reasons.
     *
     * @return array invalid properties with reasons
     */
    public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['report_date'] === null) {
            $invalidProperties[] = "'report_date' can't be null";
        }
        $allowedValues = $this->getSegmentAllowableValues();
        if (!is_null($this->container['segment']) && !in_array($this->container['segment'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'segment', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        $allowedValues = $this->getCreativeTypeAllowableValues();
        if (!is_null($this->container['creative_type']) && !in_array($this->container['creative_type'], $allowedValues, true)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'creative_type', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        if ($this->container['metrics'] === null) {
            $invalidProperties[] = "'metrics' can't be null";
        }
        return $invalidProperties;
    }

    /**
     * Validate all the properties in the model
     * return true if all passed
     *
     * @return bool True if all properties are valid
     */
    public function valid()
    {
        return count($this->listInvalidProperties()) === 0;
    }


    /**
     * Gets report_date
     *
     * @return string
     */
    public function getReportDate()
    {
        return $this->container['report_date'];
    }

    /**
     * Sets report_date
     *
     * @param string $report_date Date in YYYYMMDD format. The report only contains performance data for the specified date. The time zone is specified by the profile used to request the report. If this date is today, then the performance report may contain partial information. Reports are not available for data older than 60 days. For details on data latency, see [Service Guarantees](../../reference/concepts/developer-notes).
     *
     * @return $this
     */
    public function setReportDate($report_date)
    {
        $this->container['report_date'] = $report_date;

        return $this;
    }

    /**
     * Gets segment
     *
     * @return string
     */
    public function getSegment()
    {
        return $this->container['segment'];
    }

    /**
     * Sets segment
     *
     * @param string $segment Optional. Allows you to run a report based on secondary dimensions. Use `placement` to segment a `campaigns` report by the location on a page where your ad appears. Use `query` to segment a `keywords` report and create a search terms report.
     *
     * @return $this
     */
    public function setSegment($segment)
    {
        $allowedValues = $this->getSegmentAllowableValues();
        if (!is_null($segment) && !in_array($segment, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'segment', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['segment'] = $segment;

        return $this;
    }

    /**
     * Gets creative_type
     *
     * @return string
     */
    public function getCreativeType()
    {
        return $this->container['creative_type'];
    }

    /**
     * Sets creative_type
     *
     * @param string $creative_type Optional. Supported values are `video` (for video campaigns) and `all` (for both non-video and video campaigns). If not specified, the report will contain data for non-video campaigns. For `ads` report types only, `creativeType` is required and must be set to `all` (`video` is not allowed). To return performance data for [multi-ad group campaigns](https://advertising.amazon.com/API/docs/en-us/sponsored-brands/3-0/openapi/prod#/Campaigns), you must include `creativeType` set to `all`` in your request.
     *
     * @return $this
     */
    public function setCreativeType($creative_type)
    {
        $allowedValues = $this->getCreativeTypeAllowableValues();
        if (!is_null($creative_type) && !in_array($creative_type, $allowedValues, true)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'creative_type', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['creative_type'] = $creative_type;

        return $this;
    }

    /**
     * Gets metrics
     *
     * @return string
     */
    public function getMetrics()
    {
        return $this->container['metrics'];
    }

    /**
     * Sets metrics
     *
     * @param string $metrics Each report type supports different metrics. **To understand supported metrics for each report type, see [Report types](/API/docs/en-us/guides/reporting/v2/report-types).**
     *
     * @return $this
     */
    public function setMetrics($metrics)
    {
        $this->container['metrics'] = $metrics;

        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     *
     * @param integer $offset Offset
     *
     * @return boolean
     */
    #[\ReturnTypeWillChange]
    public function offsetExists($offset)
    {
        return isset($this->container[$offset]);
    }

    /**
     * Gets offset.
     *
     * @param integer $offset Offset
     *
     * @return mixed
     */
    #[\ReturnTypeWillChange]
    public function offsetGet($offset)
    {
        return isset($this->container[$offset]) ? $this->container[$offset] : null;
    }

    /**
     * Sets value based on offset.
     *
     * @param integer $offset Offset
     * @param mixed   $value  Value to be set
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetSet($offset, $value)
    {
        if (is_null($offset)) {
            $this->container[] = $value;
        } else {
            $this->container[$offset] = $value;
        }
    }

    /**
     * Unsets offset.
     *
     * @param integer $offset Offset
     *
     * @return void
     */
    #[\ReturnTypeWillChange]
    public function offsetUnset($offset)
    {
        unset($this->container[$offset]);
    }

    /**
     * Gets the string presentation of the object
     *
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) { // use JSON pretty print
            return json_encode(
                ObjectSerializer::sanitizeForSerialization($this),
                JSON_PRETTY_PRINT
            );
        }

        return json_encode(ObjectSerializer::sanitizeForSerialization($this));
    }
}
